import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";
import { ReqPage, ResPage } from "../interface";

export namespace DictType {
  export interface ReqDictType extends ReqPage {
    id: string;
    name: string;
    type: string;
    sort: number;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date;
    isDeleted: boolean;
  }
  export interface ResDictType {
    id: string;
    name: string;
    type: string;
    sort: number;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date;
    isDeleted: boolean;
  }
  export interface ResDictSimpleData {
    dictType: string;
    label: string;
    value: string;
  }
}

export const getSimpleDictDataList = () => {
  return http.get<DictType.ResDictSimpleData[]>(PORT1 + `/system/sys-dict-data/simple-list`);
};

export const page = (params: DictType.ReqDictType) => {
  return http.get<ResPage<DictType.ResDictType>>(PORT1 + `/sys-dict-type/page`, params);
};

export const save = (params: DictType.ReqDictType) => {
  return http.post<ResPage<DictType.ResDictType>>(PORT1 + `/sys-dict-type/save`, params);
};
export const update = (params: DictType.ReqDictType) => {
  return http.put<ResPage<DictType.ResDictType>>(PORT1 + `/sys-dict-type/update`, params);
};

export const deleteById = (id: number) => {
  return http.delete<ResPage<DictType.ResDictType>>(PORT1 + `/sys-dict-type/delete/${id}`);
};
